package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.PlanFlow;
import com.indusfo.spc.service.PlanFlowService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author: 熊冰
 * @Date: 2019/11/9 13:11
 * 任务单流程
 */

@Controller
@RequestMapping("/planFlow")
public class PlanFlowController {
	@Autowired
	private PlanFlowService planFlowService;

	//查询
	@RequestMapping(value="/queryPlanFlow")
	@ResponseBody
	public JSONObject queryPlanFlow(PlanFlow planFlow) {
		JSONObject json = planFlowService.queryPlanFlow(planFlow);
		return json;
	}

	//新增
	@RequestMapping(value="/insertPlanFlow", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject insertPlanFlow(PlanFlow planFlow) {
		JSONObject json = planFlowService.insertPlanFlow(planFlow);
		return json;
	}

	//修改
	@RequestMapping(value = "/updatePlanFlow",method= RequestMethod.POST)
	@ResponseBody
	public JSONObject updatePlanFlow (PlanFlow planFlow){
		JSONObject json=planFlowService.updatePlanFlow(planFlow);
		return json;
	}

	//删除
	@RequestMapping(value="/deletePlanFlow", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject deletePlanFlow(@RequestParam("planFlowIds") List<Integer> planFlowIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planFlowService.deletePlanFlow(planFlowIds, dataState);
		return json;
	}

	//启用
	@RequestMapping(value="/startPlanFlow", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject startPlanFlow(@RequestParam("planFlowIds") List<Integer> planFlowIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planFlowService.deletePlanFlow(planFlowIds, dataState);
		return json;
	}

	//停用
	@RequestMapping(value="/stopPlanFlow", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject stopPlanFlow(@RequestParam("planFlowIds") List<Integer> planFlowIds, Integer dataState) {
		dataState = 2;
		JSONObject json = planFlowService.deletePlanFlow(planFlowIds, dataState);
		return json;
	}





}
